using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public enum ePeripheralType
{
    None = 0,
    Mouse = 1,
    Keyboard = 2,
}

// 外设基类，可以选择连接方式连接到终端
public class Peripheral : IElementBase
{
    public ePeripheralType PeripheralType { get; set; }
    
    // 设备名字
    public string PeripheralName { get; set; }
    
    // 目标终端
    private Termina targetTermina;

    // 连接方式
    private LinkStrategy linkStrategy;
    
    public void Init(Termina targetTermina, LinkStrategy linkStrategy)
    {
        this.targetTermina = targetTermina;
        this.linkStrategy = linkStrategy;
    }

    public string SendMessage()
    {
        return linkStrategy.SendData(this, targetTermina);
    }

    public void ReSetPeripheral()
    {
        targetTermina = null;
        linkStrategy = null;
    }

    public string GetElementName()
    {
        return PeripheralName;
    }
}


public class Mouse : Peripheral
{
    public Mouse()
    {
        PeripheralName = "Mouse";
        PeripheralType = ePeripheralType.Mouse;
    }
}

public class Keyboard : Peripheral
{
    public Keyboard()
    {
        PeripheralName = "Keyboard";
        PeripheralType = ePeripheralType.Keyboard;
    }
}
